const path = require("path");
const { exec } = require("child_process");
const shell = require("shelljs");
const demoPath = path.join(__dirname, "../template/demo");
// const testPath = path.join(__dirname, "../template/test");
shell.cd(demoPath);

function execP(cmd) {
  return new Promise((resolve, reject) => {
    exec(cmd, (err) => {
      if (err) reject(err);
      else resolve(null);
    });
  });
}

execP("git add .")
  .then(() => execP("git commit -m 'publish'"))
  .then(() => execP("git push -f origin master"))
  .then(() => {
    console.log("success");
  }) 
  .catch(console.log("start"));
